<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>edit</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript">

        $(function() {
            init();
        });

        function init() {
            var text = $("#prevBlock").text(); //先取出未转换格式前端数据
            var des = text.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');  //转换格式
            $("#prevBlock").empty();
            $("#prevBlock").append(des);
        }
    </script>
</head>

<body>


<h3>编辑合同定制模板</h3>
<form name="editContractForm" th:action="@{/contract/updateCustomContract}" method="post">
    标题：<input type="text" name="name" th:value="${contract.name}"/><br/>
    类型：<select name="contractType">
    <option value="销售合同" th:selected="${contract.contractType == '销售合同'}">销售合同</option>
    <option value="采购合同" th:selected="${contract.contractType == '采购合同'}">采购合同</option>
    <option value="保密合同" th:selected="${contract.contractType == '保密合同'}">保密合同</option>
    <!--其它合同类型-->
</select><br/>
    简介：<textarea name="contractRecord.remark" th:text="${contract.contractRecord.remark}" rows="5"
                 cols="20"></textarea><br/>
    <button onclick="">添加步骤(前端未实现)</button>
    <br/>
    <div th:each="contractItem:${contract.contractSteps[0].contractItems}">
        内容<span th:text="${contractItemStat.index+1}"></span>：
        <textarea th:name="'contractSteps[0].contractItems['+${#strings.toString(contractItemStat.index)}+'].attributeValue'"
                  th:text="${contractItem.attributeValue}"
                  rows="15" cols="50" style="width: 120mm;"></textarea><br/>
    </div>
    <!--其它字段-->

    <input type="hidden" name="id" th:value="${contract.id}"/>
    <input type="hidden" name="contractSteps[0].id" th:value="${contract.contractSteps[0].id}"/>
    <input type="hidden" name="contractSteps[0].contractItems[0].id"
           th:value="${contract.contractSteps[0].contractItems[0].id}"/>
    <input type="hidden" name="contractSteps[0].contractItems[1].id"
           th:value="${contract.contractSteps[0].contractItems[1].id}"/>
    <input type="hidden" name="contractRecord.id" th:value="${contract.contractRecord.id}"/>
    <button type="submit">提交合同</button>
</form>


<h3>合同定制模板详情</h3>
<div class="modal-body">
    <div>
        合同名称：<span th:text="${contract.name}">公司设立（新设）</span>
    </div>
    <div th:each="contractType:${contract.TYPE}" th:if="${contract.contractType == contractType}">
        合同类型：<span th:text="${contract.contractType}"></span>
    </div>
    <div>
        简介：<span th:text="${contract.contractRecord.remark}"></span>
    </div>
    <div th:each="contractItem:${contract.contractSteps[0].contractItems}">
        内容<span th:text="${contractItemStat.index+1}"></span>：<br/>
        <span id="prevBlock" th:text="${contractItem.attributeValue}" rows="15" cols="50"></span>
    </div>

    <div>
        创建时间：<span th:text="${contract.createTime}">aaaa年bb月cc日dd时ee分</span>
    </div>
    <div>
        更新时间：<span th:text="${contract.updateTime}">yyyy年mm月dd日hh时mm分</span>
    </div>
    <div>
        创建人：<span th:text="${contract.createBy}">刘</span>
    </div>
    <div>
        修改人：<span th:text="${contract.updateBy}">赵</span>
    </div>
</div>




</body>
</html>